<?php

namespace easydis\APSBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\Session\Session;

/**
 * Planifier
 *
 * @ORM\Table()
 * @ORM\Entity(repositoryClass="easydis\APSBundle\EntityRepository\PlanifierRepository")
 */
class Planifier
{
    /**
     * @var string
     *
     * @ORM\Column(name="date", type="string", length=10)
     * @ORM\Id
     */
    private $date;
    
    /**
     * @var date
     *
     * @ORM\Column(name="date_eng", type="date")
     */
    private $date_eng;
    
    /**
     * @ORM\ManyToOne(targetEntity="easydis\APSBundle\Entity\PlageHoraire", inversedBy="children", cascade={"persist"})
     * @ORM\Id
     */
    private $plagehoraire;
    
    /**
     * @ORM\ManyToOne(targetEntity="easydis\APSBundle\Entity\Poste", inversedBy="children", cascade={"persist"})
     */
    private $poste;
    
    /**
     * @ORM\ManyToOne(targetEntity="easydis\APSBundle\Entity\Salarie", cascade={"persist"})
     * @ORM\Id
     */
    private $salarie;
    
    /**
     * @ORM\ManyToOne(targetEntity="easydis\APSBundle\Entity\User")
     * @ORM\JoinColumn(name="user", referencedColumnName="username")
     */
    private $user;
    
    /**
     * @var integer
     *
     * @ORM\Column(name="ordre", type="integer", length=4)
     */
    private $ordre;
    
    public function __construct() {
        
    }

    public function affectAll($date, $salarie, $ph, $poste, $ordre) {   
        $this->date_eng = date_create_from_format('d/m/Y', $date);
        $this->date = $date;
        $this->salarie = $salarie;
        $this->plagehoraire = $ph;
        $this->poste = $poste;
        $this->ordre = $ordre;
        $this->plagehoraire->addChildren($this);
        $this->poste->addChildren($this);
    }
    
    /**
     * Get date
     *
     * @return string 
     */
    public function getDate()
    {
        return $this->date;
    }
    
    /**
     * set date
     *
     * @param string $date
     */
    public function setDate($date)
    {
        $this->date_eng = date_create_from_format('d/m/Y', $date);
        $this->date = $date;
    }
    
    /**
     * Get date_eng
     *
     * @return date
     */
    public function getDate_eng()
    {
        return $this->date_eng;
    }
    
    /**
     * Get ordre
     *
     * @return integer 
     */
    public function getOrdre()
    {
        return $this->ordre;
    }
    
    /**
     * Set ordre
     *
     * @param integer $ordre
     */
    public function setOrdre($ordre)
    {
        $this->ordre = $ordre;
    }
    
    /**
     * Set user
     *
     * @param easydis\APSBundle\Entity\User $user
     */
    public function setUser(\easydis\APSBundle\Entity\User $user)
    {
       $this->user = $user;
    }

    /**
     * Get user
     *
     * @return easydis\APSBundle\Entity\User
     */
    public function getUser()
    {
        return $this->user;
    }
    
    /**
     * Set salarie
     *
     * @param easydis\APSBundle\Entity\Salarie $salarie
     */
    public function setSalarie(\easydis\APSBundle\Entity\Salarie $salarie)
    {
            $this->salarie = $salarie;
    }

    /**
     * Get salarie
     *
     * @return easydis\APSBundle\Entity\Salarie
     */
    public function getSalarie()
    {
        return $this->salarie;
    }
    
    /**
     * Set plagehoraire
     *
     * @param easydis\APSBundle\Entity\PlageHoraire $plageHoraire
     */
    public function setPlageHoraire(\easydis\APSBundle\Entity\PlageHoraire $plageHoraire)
    {
            $this->plagehoraire = $plageHoraire;
    }

    /**
     * Get plagehoraire
     *
     * @return easydis\APSBundle\Entity\PlageHoraire
     */
    public function getPlageHoraire()
    {
        return $this->plagehoraire;
    }
    
    /**
     * Set poste
     *
     * @param easydis\APSBundle\Entity\Poste $poste
     */
    public function setPoste(\easydis\APSBundle\Entity\Poste $poste)
    {
            $this->poste = $poste;
    }

    /**
     * Get poste
     *
     * @return easydis\APSBundle\Entity\Poste
     */
    public function getPoste()
    {
        return $this->poste;
    }
    
    /**
     * Get id
     *
     * @return string
     */
    public function getId()
    {
        return $this->salarie->getId().$this->date.$this->plagehoraire->getId();
    }
    
}
